'use strict';//es5的严格模式
// 包装函数
module.exports = function(grunt){
	grunt.initConfig({
		// 获取package.json的信息
		pkg: grunt.file.readJSON('package.json'),
		jshint: {
			build: ['Gruntfile.js','src/*.js'],
			options: {
				jshintrc: '.jshintrc'
			}
		},
		uglify: {
			options: {
				stripBanners: true,
				banner: '/*!<%=pkg.name%>-<%=pkg.version%>.js <%= grunt.template.today("yyy-mm-dd")%> */\n'
			},
			build: {
				src: 'src/test.js',
				dest: 'build/<%=pkg.name%>-<%=pkg.version%>.js.min.js'
			}
		},
		watch: {
			build:{
				files: ['app/scripts/*.js','app/styles/*.css','app/*.html'],
				tasks: ['jshint','uglify'],
				options: {spawn: false}
			}
		},
		qunit: {
			all_tests: ['app/*.html'],
			individual_tests: {
				files: [
					{src: 'app/*.html'},
					{src: 'app/*.html'}
				]
			},
			urls:{
				options: {
					urls: [
					'app/index.html',
					'index.html'
					]
				}
			},
			urls_and_files: {
				options: {
					urls: '<%= quint.urls.options.urls %>'
				},
				src: 'app/*.html'
			},
			noglobals: {
				options: {
					noglobals: true,
					force: true
				},
				src: 'app/index.html'
			}
		},
		open: {
		    dev : {
		      path: 'app/index.html',
		      // app: 'Google Chrome'
		    },
		    build : {
		      path : 'http://google.com/',
		      // app: 'Firefox'
		    },
		    // file : {
		    //   path : '/etc/hosts'
		    // },
		    custom: {
		      path : function () {
		        return grunt.option('path');
		      } 
		    }
		  }
		 
	});
	// 告诉grunt我们将使用插件
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-open');
	// 告诉grunt当我们在终端中输入grunt是需要做些什么(注意先后顺序)
	grunt.registerTask('default',['jshint','uglify','open:dev','watch','qunit']);
};